package com.github.dabai.aggregation;

import java.text.SimpleDateFormat;
import java.util.Date;

public interface IGroupByFieldConvert<I> {

	String format(I input);

	class StringGroupByFieldConvert implements IGroupByFieldConvert<String> {
		@Override
		public String format(String input) {
			return input;
		}
	}

	class DateGroupByFieldConvert implements IGroupByFieldConvert<Date> {

		private String dateFormatPattern;

		public DateGroupByFieldConvert(String dateFormatPattern) {
			super();
			this.dateFormatPattern = dateFormatPattern;
		}

		@Override
		public String format(Date input) {
			SimpleDateFormat f = new SimpleDateFormat(dateFormatPattern);
			return f.format(input);
		}
	}
}
